<%@ page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ page import="com.gmail.avereshchaga.web.controller.EmployeeController"%>
<%@ page import="com.gmail.avereshchaga.web.controller.DivisionController"%>
<%@ page import="static com.gmail.avereshchaga.tools.Command.EMPLOYEE_UPDATE_COMMAND"%>
<%@ page import="static com.gmail.avereshchaga.tools.UrlList.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
        <title>	Edit employee</title>
    </head>
    <body>
        <table class="loctable" >
            <tr><td valign="top">   
		<%@ include file="login.jsp" %>     
        <form:form commandName="<%=EMPLOYEE_UPDATE_COMMAND %>" method="post">
        <table>
            <tr>
                <td><form:hidden path="id" /></td>
            </tr>
            <tr>
                <td><spring:message code="label.firstName"/>:</td>
                <td><form:input path="firstName" /></td>
                <td style="color:red;"><form:errors path="firstName" /></td>
            </tr>
            <tr>
                <td><spring:message code="label.lastName"/>:</td>
                <td><form:input path="lastName" /></td>
                <td style="color:red;"><form:errors path="lastName" /></td>
            </tr>
            <tr>
                <td><spring:message code="label.salary"/>:</td>
                <td><form:input path="salaryStr" /></td>
                <td style="color:red;"><form:errors path="salaryStr" /></td>
            </tr>
            <tr>
                <td><spring:message code="label.birthdate"/>:</td>
                <td><form:input path="birthdateStr" /></td>
                <td style="color:red;"><form:errors path="birthdateStr" /></td>
            </tr>
            <tr>
                <td><spring:message code="label.active"/>:</td>
                <td>
					<form:select path="active">
                         <option value="true" selected="selected"> <spring:message code="label.active.true"/> </option>
                         <option value="false"> <spring:message code="label.active.false"/> </option>
                    </form:select>
                </td>
            </tr>
            <tr>
            	<td><spring:message code="label.division"/>:</td>
            	<td>
				<form:select path="divisionId">
            		<c:forEach items="${divisionList}" var="division">
                        <c:choose>
                            <c:when test="${division.id == DivisionId}">
                                <option value="<c:out value="${division.id}"/>"selected><c:out value="${division.name}"/>
                            </c:when>
                            
                            <c:otherwise>
                                <option value="<c:out value="${division.id}"/>"><c:out value="${division.name}"/>
                            </c:otherwise>
                		</c:choose> 
                		
            		</c:forEach>
        		</form:select>
        		</td>
        	</tr>
        </table>
                
        <input type="submit" value="<spring:message code="label.save"/>" />
        <input onclick="history.back(-1)" value="<spring:message code="label.cancel"/>" type="button">
        </form:form>
        </td></tr>
        </table>
    </body>
</html>